/*
 * File:   Freinage_WS.c
 * Author: aravelomanantsoa@gmail.com
 */

#include <stdio.h>
#include "CAN_I.h"
#include "Utils.h"
#include "cJSON.h"

/* print JSON responses */
void printJSONResponse();

/* Main function */
int main(void) {
	int success = 0;

	printf(CONTENT_TYPE_JSON);

	success = freinage();

	if (success == CANNOT_OPEN_CAN_DEVICE) {
		printJSONErrorMsg("Cannot open CAN device!");
		return 0;
	}

	if (success == CANNOT_SEND_DATA_FRAME) {
		printJSONErrorMsg("Cannot send CAN message!");
		return 0;
	}

	printJSONResponse();

	return 0;
}

void printJSONResponse(int b) {
	cJSON *root = cJSON_CreateObject();

	/* success = TRUE */
	cJSON_AddTrueToObject(root, "success");

	printf(cJSON_Print(root));
}
